package com.nhim.cms.admin.server.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nhim.cms.dao.CustomWidgetInstanceDAO;
import com.nhim.cms.domain.CustomWidgetInstance;
import com.nhim.core.AppContext;

public class CustomWidgetInstanceLocator extends Locator<CustomWidgetInstance, Integer> {

	CustomWidgetInstanceDAO customWidgetInstanceDAO = CustomWidgetInstanceDAO.getFromApplicationContext(AppContext.getApplicationContext());
	
	@Override
	public CustomWidgetInstance create(
			Class<? extends CustomWidgetInstance> clazz) {
		return new CustomWidgetInstance();
	}

	@Override
	public CustomWidgetInstance find(
			Class<? extends CustomWidgetInstance> clazz, Integer id) {
		if (id == null)
			return new CustomWidgetInstance();
		return customWidgetInstanceDAO.findById(id);
	}

	@Override
	public Class<CustomWidgetInstance> getDomainType() {
		return CustomWidgetInstance.class;
	}

	@Override
	public Integer getId(CustomWidgetInstance domainObject) {
		return domainObject.getId();
	}

	@Override
	public Class<Integer> getIdType() {
		return Integer.class;
	}

	@Override
	public Object getVersion(CustomWidgetInstance domainObject) {
		
		return domainObject.getVersion();
	}

}
